<%@ page import="cake.Cake" %>
<%@ page import="java.util.List" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Connection" %><%--
  Created by IntelliJ IDEA.
  User: hua'wei
  Date: 2022/12/2
  Time: 22:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>购物主页</title>
    <link rel="stylesheet" href="style/cart.css">
</head>
<body>
 <ul class="report">
    <li class="report_item">
        <a href="#">首页</a>
    </li>
    <li class="report_item">
        <a href="#">食品</a>
    </li>
    <li class="report_item">
        <a href="#">女装</a>
    </li>
    <li class="report_item">
        <a href="#">男装</a>
    </li>
    <li class="report_item">
        <a href="#">鞋包</a>
    </li>
    <li class="report_item">
        <a href="#">美妆</a>
    </li>
    <li class="report_item">
        <a href="#">手机</a>
    </li>
    <li class="report_item">
        <a href="#">电脑</a>
    </li>
</ul>
<div class="toSearch">
    <input type="search" placeholder="请输入要的搜索商品">
    <button type="button">搜索</button>
</div>
<div class="mylunbo">
    <a href="javascript:;" class="arrow-l"><</a>
    <a href="javascript:;" class="arrow-r">></a>
    <ul>
        <li>
            <a href="#"><img src="style/1.png"  alt="" /></a>
        </li>
        <li>
            <a href="#"><img src="style/2.png"  alt="" /></a>
        </li>
        <li>
            <a href="#"><img src="style/3.png"  alt="" /></a>
        </li>
        <li>
            <a href="#"><img src="style/4.png"  alt="" /></a>
        </li>
    </ul>
    <ol class="circle">

    </ol>
</div>
<script src="style/cart.js"></script>
    <div class="table">
        <br>
        <br>
        <h3>———————— 商品列表 ————————</h3>
        <br>
        <br>
        <table class="biao" >
            <tr>
                <th>序号</th>
                <th>商品名称</th>
                <th>价格</th>
                <th>数量</th>
                <th>操作</th>
            </tr>
            <%
                String driverClass = "com.mysql.cj.jdbc.Driver";
                String url = "jdbc:mysql://localhost:3306/cart?serverTimezone=Asia/Shanghai";
                String user = "root";
                String password = "111111";
                Connection conn;
                try {
                    Class.forName(driverClass);
                    conn = DriverManager.getConnection(url, user, password);
                    Statement stmt = conn.createStatement();
                    String sql = "select * from shop";
                    ResultSet rs = stmt.executeQuery(sql);
                    while (rs.next()) {
            %>
            <tr align="center">
                <td><%=rs.getString("id")%>
                </td>
                <td><a href="detail.jsp?shop=<%=rs.getString("shop")%>"/><%=rs.getString("shop")%>
                </td>
                <td><%=rs.getString("price")%>
                </td>
                <td><%=rs.getString("num")%>
                </td>
                <td><a href="account.jsp?shop=<%=rs.getString("shop")%>">加入购物车</a></td>
            </tr>
            <%
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            %>
        </table>
    </div>

</body>
</html>
